package com.nsoft.thickclient.trackMove.util;

import java.awt.FlowLayout;

import javax.swing.Box;
import javax.swing.JPanel;

import com.nsoft.thickclient.beanUtils.ActionDescriptor;
import com.nsoft.thickclient.beanUtils.NButton;
import com.nsoft.thickclient.controller.ScreenController;

public class TrackMoveButtonPanel extends JPanel {

	/**
	 * serialVersionUID = 1L.
	 */
	private static final long serialVersionUID = 1L;

	private NButton saveButton;

	public TrackMoveButtonPanel(ScreenController controller, boolean editMode) {
		ActionDescriptor saveAction = new ActionDescriptor("Save", "doSave",
				controller);

		ActionDescriptor newAction = new ActionDescriptor("New", "doNew",
				controller);

		ActionDescriptor cancelAction = new ActionDescriptor("Cancel",
				"doCancel", controller);
		setLayout(new FlowLayout(FlowLayout.CENTER));
		saveButton = new NButton(saveAction, editMode);
		add(saveButton);
		add(Box.createHorizontalStrut(20));
		add(new NButton(newAction, !editMode));
		add(Box.createHorizontalStrut(20));
		add(new NButton(cancelAction));
	}

	public void enableSave(boolean enable) {
		saveButton.setEnabled(enable);
	}
}
